<?php

error_reporting(E_ALL);

/**
 * AplicacionWeb - class.ModeloSalida.php
 *
 * $Id$
 *
 * This file is part of AplicacionWeb.
 *
 * Automatically generated on 01.12.2011, 13:10:44 with ArgoUML PHP module 
 * (last revised $Date: 2010-01-12 20:14:42 +0100 (Tue, 12 Jan 2010) $)
 *
 * @author firstname and lastname of author, <author@example.org>
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/**
 * Clase que se encarga del control del acceso a la persistencia de los datos 
 * Centraliza la conexiones en los modelos
 *
 * @author Ivan R. Chenoweth
 * @since 2011
 * @version 1
 */
require_once('class.Conexion.php');

/* user defined includes */
// section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021D9-includes begin
// section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021D9-includes end

/* user defined constants */
// section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021D9-constants begin
// section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021D9-constants end

/**
 * Short description of class ModeloSalida
 *
 * @access public
 * @author firstname and lastname of author, <author@example.org>
 */
class ModeloSalida
    extends Conexion
{
    // --- ASSOCIATIONS ---


    // --- ATTRIBUTES ---

    // --- OPERATIONS ---

    /**
     * Short description of method insertRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  datos
     * @return mixed
     */
    public function insertRow($datos)
    {
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021DA begin
        //$_SESSION["userRow"]["id"]
		//var_dump($datos);
		//$_SESSION["userRow"]["Usuario_Id"];
		//$sql = "INSERT INTO salidas(SalidaNumeroFolio, Empleado_Id, Usuario_Id, SalidaFecha) VALUES (".$datos["folio"].",".$datos["emp"].",".$sesionUser.", '". date("Y-m-d") ."')";     
		$sesionUser=1;
		$sql = "INSERT INTO salidas(SalidaNumeroFolio, Empleado_Id, Usuario_Id, SalidaFecha) VALUES (".$datos["folio"].",".$datos["emp"].",".$sesionUser.", '". date("Y-m-d") ."')";     
		$row0 = $this->ejecutarQuery($sql);
		//var_dump($row0);
		//echo mysql_insert_id($row0);
		//return last_inserted_id($row0);
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021DA end
    }

    /**
     * Short description of method getNextFolio
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function getNextFolio()
    {
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021DD begin
		//$sql = "SELECT MAX(SalidaNumeroFolio) FROM salidas ORDER BY SalidaNumeroFolio DESC LIMIT 1";
        $sql = "SELECT SalidaNumeroFolio FROM salidas ORDER BY SalidaNumeroFolio DESC LIMIT 1";        
		$row0 = $this->ejecutarQuery($sql);
		$n =  @$row0[0][SalidaNumeroFolio];
		$n = $n + 1;		
		return $n;
        // section 10-25-3-74-25c3b17:133af115f13:-8000:00000000000021DD end
    }

    /**
     * Short description of method lastRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function lastRow()
    {
        // section -64--88-3-36--f7fa13e:133fb3a5af6:-8000:0000000000001B8D begin
		$sql = "SELECT MAX(Salida_Id) as maximo FROM salidas";     
		$row = $this->ejecutarQuery($sql);
		return $row[0]['maximo'];
        // section -64--88-3-36--f7fa13e:133fb3a5af6:-8000:0000000000001B8D end
    }

	public function Buscar($id)
    {
        // section -64--88-3-36--f7fa13e:133fb3a5af6:-8000:0000000000001B8D begin
		$sql = "SELECT * FROM salidas WHERE Salida_Id=".$id;     
		$row = $this->ejecutarQuery($sql);
		return $row;
        // section -64--88-3-36--f7fa13e:133fb3a5af6:-8000:0000000000001B8D end
    }

} /* end of class ModeloSalida */

?>